﻿using BigEgg.Framework.Foundation;
using FMStudio.Domain.Properties;
using FMStudio.Domain.Test.MockClasses;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace FMStudio.Domain.Test
{
    [TestClass]
    public class BillTest
    {
        [TestMethod]
        public void BillPayTypeValidationTest()
        {
            MockBill bill = new MockBill();

            Assert.IsNull(bill.PayTypeString);
            Assert.AreEqual(Resources.PayTypeMandatory, bill.Validate("PayTypeString"));

            bill.PayTypeString = "000001";
            Assert.AreEqual("", bill.Validate("PayTypeString"));
            bill.PayTypeString = "100001";
            Assert.AreEqual("", bill.Validate("PayTypeString"));
        }

        [TestMethod]
        public void BillUseTypeValidationTest()
        {
            MockBill bill = new MockBill();

            Assert.IsNull(bill.UseType);
            Assert.AreEqual(Resources.UseTypeMandatory, bill.Validate("UseType"));

            MockUseType useType = new MockUseType();
            bill.UseType = useType;
            Assert.AreEqual("", bill.Validate("UseType"));
        }

        [TestMethod]
        public void BillItemPriceValidationTest()
        {
            MockBill bill = new MockBill();

            Assert.IsNull(bill.ItemPrice);
            Assert.AreEqual(Resources.ItemPriceMandatory, bill.Validate("ItemPrice"));

            MockItemPrice itemPrice = new MockItemPrice();
            bill.ItemPrice = itemPrice;
            Assert.AreEqual("", bill.Validate("ItemPrice"));
        }

        [TestMethod]
        public void BillNumberValidationTest()
        {
            MockBill bill = new MockBill();

            Assert.AreEqual(default(double), bill.Number);

            bill.Number = 0.1;
            Assert.AreEqual("", bill.Validate("Number"));
            bill.Number = 0.0;
            Assert.AreEqual(Resources.BillNumberGreater, bill.Validate("Number"));
            bill.Number = -0.1;
            Assert.AreEqual(Resources.BillNumberGreater, bill.Validate("Number"));
        }

        [TestMethod]
        public void BillDiscountValidationTest()
        {
            MockBill bill = new MockBill();

            Assert.AreEqual(default(double), bill.Discount);

            bill.Discount = 0.1;
            Assert.AreEqual("", bill.Validate("Discount"));
            bill.Discount = 0.0;
            Assert.AreEqual("", bill.Validate("Discount"));
            bill.Discount = -0.1;
            Assert.AreEqual(Resources.BillDiscountGreaterOrEqual, bill.Validate("Discount"));
        }
    }
}
